<?php include "../public/header.php";?>
<?php include "../public/header_public.php";?>
<link rel='stylesheet' href='/static/admin/css/home.css'>
<style>
    .xm-label-block{border: unset!important;}
    .xm-label-block span{font-size: 16px!important;}
    .xm-icon-close{display: none!important;}
    .leftengin .tuo:hover,.danbox:hover{background: #f6f6f6 !important;}
    #role1{float: left}
    #role2{padding-left: 20px;line-height: 30px;float: left}
    #role3{padding-left: 20px;line-height: 30px;float: left}
    .busdiv{width: 200px;float: left;margin-left: 20px}
    .busdiv input{height: 30px!important;}
</style>
<body id="homePage">
<div id="homeBox">
    <div class="minbox" style="margin-bottom: 10px;padding-top: 10px;height: 40px;">
        <div id="role1" class="rolecc layui-hide">
            <div id="chanid" class="xmselect_div" style="width: 300px;height: 40px;margin-left: 20px"></div>
        </div>
        <div id="role2" class="rolecc layui-hide">

        </div>
        <div id="role3" class="rolecc layui-hide">

        </div>

        <div id="enginidstr" class="layui-hide"></div>

        <div class="busdiv layui-form">
            <select id="business" name="business" lay-filter="business">
                <option value="">项目属性</option>
                <option value="1">自营</option>
                <option value="2">联营</option>
            </select>
        </div>
        <div class="busdiv layui-form">
            <input type="text" id="dts" name="dts" placeholder="请选择" autocomplete="off" class="layui-input bdate_sea_range_ymd_cur">
        </div>
    </div>
    <div class="leftengin">
        <div class="tongbox tongbox7">
            <div class="tuo">
                <div class="tit">项目总数</div>
                <div class="con colorlan" id="tong_all"></div>
            </div>
            <div class="tuo">
                <div class="tit">在建项目总数</div>
                <div class="con colorlan" id="tong_zai"></div>
            </div>
            <div class="tuo">
                <div class="tit">施工合同总额(含变更)</div>
                <div class="con colorlan" id="tong_shimoney"></div>
            </div>
            <div class="tuo">
                <div class="tit">累计审定产值总额 A</div>
                <div class="con colorlan" id="tong_chan"></div>
            </div>
            <div class="tuo">
                <div class="tit">开票总额</div>
                <div class="con colorlan" id="tong_piaokai"></div>
            </div>
            <div class="tuo">
                <div class="tit">回款总额 B</div>
                <div class="con colorlan" id="tong_huikuan"></div>
            </div>
            <div class="tuo">
                <div class="tit">未回款总额 A-B</div>
                <div class="con colorlan" id="tong_nohuikuan"></div>
            </div>
        </div>
        <div class="tongbox tongbox7">
            <div class="tuo">
                <div class="tit">采购合同金额</div>
                <div class="con colorlan" id="tong_caimoney"></div>
            </div>
            <div class="tuo">
                <div class="tit">供应商结算金额</div>
                <div class="con colorlan" id="tong_jie"></div>
            </div>
            <div class="tuo">
                <div class="tit">收票总额</div>
                <div class="con colorlan" id="tong_piaoshou"></div>
            </div>
            <div class="tuo">
                <div class="tit">供应商付款总额 C</div>
                <div class="con colorlan" id="tong_payment_engin"></div>
            </div>
            <div class="tuo">
                <div class="tit">费用报销总额 D</div>
                <div class="con colorlan" id="tong_payment_bao"></div>
            </div>
            <div class="tuo">
                <div class="tit">其他付款总额 E</div>
                <div class="con colorlan" id="tong_neifu"></div>
            </div>
            <div class="tuo">
                <div class="tit">收付差 B-(C+D+E)</div>
                <div class="con colorlan" id="tong_cha"></div>
            </div>
        </div>
        <div class="minbox" style="margin-top: 20px;margin-bottom: 10px;padding-top: 10px;height: 40px;">
            <div id="enginid" class="xmselect_div" style="width: 500px;height: 40px;margin-left: 20px"></div>
        </div>

        <div id="daninfo">
            <div class="dan_left hei70 bg1">项目概况</div>
            <div class="dan_right">
                <div class="tou bgrr1">
                    <div>项目性质</div>
                    <div>项目状态</div>
                    <div>所属单位</div>
                    <div>甲方单位</div>
                    <div>业务对接人</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="gai_business_name"></div>
                    <div id="gai_state_name"></div>
                    <div id="gai_chanid_name"></div>
                    <div id="gai_jian_unit"></div>
                    <div id="gai_man_xiang_name"></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei140 bg2">项目收入</div>
            <div class="dan_right">
                <div class="tou bgrr2">
                    <div>施工合同含变更</div>
                    <div>累计审定产值A</div>
                    <div>累计开票B</div>
                    <div>累计回款C</div>
                    <div>产值回款比C/A</div>
                    <div>垫资金额</div>
                </div>
                <div class="nei">
                    <div id="income_shimoney"></div>
                    <div id="income_chan"></div>
                    <div id="income_piaokai"></div>
                    <div id="income_huikuan"></div>
                    <div id="income_chanhui"></div>
                    <div id="income_diankuan"></div>
                </div>
                <div class="tou bgrr2">
                    <div>应收未收（按产值）A-C</div>
                    <div>应收未收（按开票）B-C</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="income_ying_chan"></div>
                    <div id="income_ying_kai"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei140 bg3">项目支出</div>
            <div class="dan_right">
                <div class="tou bgrr3">
                    <div>采购合同含变更</div>
                    <div>供应商累计结算A</div>
                    <div>供应商累计付款B</div>
                    <div>项目费用报销C</div>
                    <div>累计收票D</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="payment_caimoney"></div>
                    <div id="payment_leijie"></div>
                    <div id="payment_payengin"></div>
                    <div id="payment_paybao"></div>
                    <div id="payment_piaoshou"></div>
                    <div></div>
                </div>
                <div class="tou bgrr3">
                    <div>应付未付（按结算）A-B</div>
                    <div>应付未付（按收票）D-B-C</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="payment_ying_jie"></div>
                    <div id="payment_ying_shou"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei280 bg4">项目成本</div>
            <div class="dan_right">
                <div class="tou bgrr4">
                    <div>预算金额含变更A</div>
                    <div>采购合同含变更B</div>
                    <div>采购合同预算占比B/A</div>
                    <div>供应商累计结算</div>
                    <div>支出付款金额</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="cheng_budget"></div>
                    <div id="cheng_caimoney"></div>
                    <div id="cheng_yubi"></div>
                    <div id="cheng_leijie"></div>
                    <div id="cheng_fukuan"></div>
                    <div></div>
                </div>
                <div class="tou bgrr4">
                    <div>材料合同</div>
                    <div>劳务合同</div>
                    <div>租赁合同</div>
                    <div>分包合同</div>
                    <div>其他合同</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="cheng_cai_cai"></div>
                    <div id="cheng_cai_lao"></div>
                    <div id="cheng_cai_zu"></div>
                    <div id="cheng_cai_fen"></div>
                    <div id="cheng_cai_qi"></div>
                    <div></div>
                </div>
                <div class="tou bgrr4">
                    <div>材料结算</div>
                    <div>劳务结算</div>
                    <div>租赁结算</div>
                    <div>分包结算</div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="cheng_jie_stuff"></div>
                    <div id="cheng_jie_labour"></div>
                    <div id="cheng_jie_device"></div>
                    <div id="cheng_jie_subbao"></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="tou bgrr4">
                    <div>材料付款</div>
                    <div>劳务付款</div>
                    <div>租赁付款</div>
                    <div>分包付款</div>
                    <div>措施费</div>
                    <div>项目费用报销</div>
                </div>
                <div class="nei">
                    <div id="cheng_fu_stuff"></div>
                    <div id="cheng_fu_labour"></div>
                    <div id="cheng_fu_device"></div>
                    <div id="cheng_fu_subbao"></div>
                    <div id="cheng_fu_cuo"></div>
                    <div id="cheng_fu_bao"></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg5">项目现金流</div>
            <div class="dan_right">
                <div class="tou bgrr5">
                    <div>项目到账总额A</div>
                    <div>项目实际支付B</div>
                    <div>项目现金余额A-B</div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="xian_daofee"></div>
                    <div id="xian_zhifee"></div>
                    <div id="xian_yufee"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg6">项目发票</div>
            <div class="dan_right">
                <div class="tou bgrr6">
                    <div>累计开票</div>
                    <div>销项税额A</div>
                    <div>累计收票</div>
                    <div>进项税额B</div>
                    <div>应缴增值税额A-B</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="piao_kai"></div>
                    <div id="piao_xiao"></div>
                    <div id="piao_shou"></div>
                    <div id="piao_jin"></div>
                    <div id="piao_ying"></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg7">项目进度</div>
            <div class="dan_right">
                <div class="tou bgrr7">
                    <div>计划总产值A</div>
                    <div>开累完成产值B</div>
                    <div>产值完成比B/A</div>
                    <div>实际开工日期</div>
                    <div>施工天数</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="jin_chanfee"></div>
                    <div id="jin_wanchan"></div>
                    <div id="jin_wanbi"></div>
                    <div id="jin_actualdt"></div>
                    <div id="jin_shiday"></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg8">质安巡检</div>
            <div class="dan_right">
                <div class="tou bgrr8">
                    <div>巡检次数</div>
                    <div>整改通知数</div>
                    <div>已整改</div>
                    <div>待整改</div>
                    <div>逾期未整改</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="xun_xunci"></div>
                    <div id="xun_zhengci"></div>
                    <div id="xun_yizheng"></div>
                    <div id="xun_daizheng"></div>
                    <div id="xun_yuzheng"></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei140 bg9">项目内包</div>
            <div class="dan_right">
                <div class="tou bgrr9">
                    <div>委托方</div>
                    <div>项目收款A</div>
                    <div>累计扣款登记B</div>
                    <div>累计内包付款C</div>
                    <div>供应商累计付款D</div>
                    <div>项目费用报销E</div>
                </div>
                <div class="nei">
                    <div id="nei_lian_unit"></div>
                    <div id="nei_xiangshou"></div>
                    <div id="nei_kou"></div>
                    <div id="nei_fu"></div>
                    <div id="nei_gongfu"></div>
                    <div id="nei_bao"></div>
                </div>
                <div class="tou bgrr9">
                    <div>项目可用资金A-B-C-D-E</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="nei_keyong"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>

            <div style="clear: both;"></div>
        </div>


    </div>
    <div class="rightengin">
        <div class="tits"><b>项目动态</b></div>
        <div class="chadt">
            <input type="text" id="dongdt" placeholder="请选择" autocomplete="off" class="layui-input bdate_dongdt">
        </div>
        <div class="linecon">
            <ul class="layui-timeline" id="dongList"></ul>
        </div>
    </div>

</div>
<script>
    $('#dongList').on('mouseover','p',function () {
        $(this).addClass('colorlan');
    }).on('mouseout','p',function () {
        $(this).removeClass('colorlan');
    });

    layui.use(['form', 'layer', "laytp",'element','dropdown'], function() {
        var form = layui.form,element = layui.element;
        get_engin_chan_home();

        var laydate = layui.laydate;
        lay('.bdate_sea_range_ymd_cur').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'date'
                ,range: true
                ,done: function(value, date, endDate){
                    setTimeout(function () {
                        get_engin_chan_home();
                    },200)
                }
            });
        });


        form.on('select(business)', function(data){
            get_engin_chan_home();
        });


        function get_engin_chan_home(chanid=0){
            setTimeout(function () {
                var chanid = $("input[name='chanid']").val() || 0;
                var business = $("#business").val();
                var dts = $("#dts").val();

                facade.ajax({url: ask_engin_chan_home, data:{chanid:chanid, business:business, dts:dts}}).done(function(res){
                    if (res.code === 2000) {
                        var data = res.data;
                        $("#tong_all").html(data.tong_all);
                        $("#tong_zai").html(data.tong_zai);
                        $("#tong_shimoney").html(parseFormatNum(data.tong_shimoney));
                        $("#tong_chan").html(parseFormatNum(data.tong_chan));
                        $("#tong_piaokai").html(parseFormatNum(data.tong_piaokai));
                        $("#tong_huikuan").html(parseFormatNum(data.tong_huikuan));
                        $("#tong_nohuikuan").html(parseFormatNum(data.tong_nohuikuan));

                        $("#tong_caimoney").html(parseFormatNum(data.tong_caimoney));
                        $("#tong_jie").html(parseFormatNum(data.tong_jie));
                        $("#tong_piaoshou").html(parseFormatNum(data.tong_piaoshou));
                        $("#tong_payment_engin").html(parseFormatNum(data.tong_payment_engin));
                        $("#tong_payment_bao").html(parseFormatNum(data.tong_payment_bao));
                        $("#tong_neifu").html(parseFormatNum(data.tong_neifu));
                        $("#tong_cha").html(parseFormatNum(data.tong_cha));


                        $("#enginidstr").text(data.enginidstr);

                        if(data.token_roletype == 1){
                            xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                                get_engin_chan_home(res.change[0].id)
                            })
                            $("#role1").removeClass('layui-hide');
                        }
                        if(data.token_roletype == 2){
                            $("#role2").removeClass('layui-hide').html(data.xianname);
                        }
                        if(data.token_roletype == 3){
                            $("#role3").removeClass('layui-hide').html(data.xianname);
                        }

                        render_from();
                        get_engin_dong_home();
                        get_engin_dan_home();
                    }
                });
            },300);



        }


        $('.bdate_dongdt').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: "month",
            initialDate: new Date(),
            autoclose: true,
            todayBtn: true,
        }) .on('changeDate',function (e) {
            get_engin_dong_home($("#dongdt").val())
        });

        function get_engin_dong_home(dt=''){
            var enginidstr = $("#enginidstr").text();
            facade.ajax({url: ask_engin_dong_home, data:{enginidstr:enginidstr, dt:dt}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data;
                    var list = res.data.data;
                    $("#dongdt").val(data.isdt);

                    var str = '';
                    if(list.length > 0){
                        for (var key in list){
                            str += '<li class="layui-timeline-item">';
                            str += '<i class="layui-icon layui-timeline-axis">&#xe643;</i>';
                            str += '<div class="layui-timeline-content layui-text">';
                            str += '<div class="layui-timeline-title" style="font-size: 14px!important;">';
                            str += list[key].created_time;
                            if(list[key].status == 0){
                                str += '<span class="colorlan" style="font-size: 12px!important;">（进行中）</span>';
                            }
                            str += '</div>';
                            str += '<p>'+list[key].summary+'</p>';
                            str += '</div>';
                            str += '</li>';
                        }
                    }else{
                        str += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }



                    $("#dongList").html(str);
                    render_from();
                }
            });
        }
        function get_engin_dan_home(enginid=0){
            $("#daninfo .con").html('');
            xmselect_dan('enginid', [], '');

            var enginidstr = $("#enginidstr").text();
            facade.ajax({url: ask_engin_dan_home, data:{enginidstr:enginidstr, enginid:enginid}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data;

                    if(!data.isinfo){
                        return false;
                    }

                    $("#gai_business_name").html(data.gai_business_name);
                    $("#gai_state_name").html(data.gai_state_name);
                    $("#gai_chanid_name").html(data.gai_chanid_name);
                    $("#gai_jian_unit").html(data.gai_jian_unit);
                    $("#gai_man_xiang_name").html(data.gai_man_xiang_name);


                    $("#income_shimoney").html(parseFormatNum(data.income_shimoney));
                    $("#income_chan").html(parseFormatNum(data.income_chan));
                    $("#income_piaokai").html(parseFormatNum(data.income_piaokai));
                    $("#income_huikuan").html(parseFormatNum(data.income_huikuan));
                    $("#income_chanhui").html(parseFormatNum(data.income_chanhui));
                    $("#income_diankuan").html(parseFormatNum(data.income_diankuan));
                    $("#income_ying_chan").html(parseFormatNum(data.income_ying_chan));
                    $("#income_ying_kai").html(parseFormatNum(data.income_ying_kai));


                    $("#payment_caimoney").html(parseFormatNum(data.payment_caimoney));
                    $("#payment_leijie").html(parseFormatNum(data.payment_leijie));
                    $("#payment_payengin").html(parseFormatNum(data.payment_payengin));
                    $("#payment_paybao").html(parseFormatNum(data.payment_paybao));
                    $("#payment_piaoshou").html(parseFormatNum(data.payment_piaoshou));
                    $("#payment_ying_jie").html(parseFormatNum(data.payment_ying_jie));
                    $("#payment_ying_shou").html(parseFormatNum(data.payment_ying_shou));


                    $("#cheng_budget").html(parseFormatNum(data.cheng_budget));
                    $("#cheng_caimoney").html(parseFormatNum(data.cheng_caimoney));
                    $("#cheng_yubi").html(parseFormatNum(data.cheng_yubi));
                    $("#cheng_leijie").html(parseFormatNum(data.cheng_leijie));
                    $("#cheng_fukuan").html(parseFormatNum(data.cheng_fukuan));

                    $("#cheng_cai_cai").html(parseFormatNum(data.cheng_cai_cai));
                    $("#cheng_cai_lao").html(parseFormatNum(data.cheng_cai_lao));
                    $("#cheng_cai_zu").html(parseFormatNum(data.cheng_cai_zu));
                    $("#cheng_cai_fen").html(parseFormatNum(data.cheng_cai_fen));
                    $("#cheng_cai_qi").html(parseFormatNum(data.cheng_cai_qi));

                    $("#cheng_jie_stuff").html(parseFormatNum(data.cheng_jie_stuff));
                    $("#cheng_jie_labour").html(parseFormatNum(data.cheng_jie_labour));
                    $("#cheng_jie_device").html(parseFormatNum(data.cheng_jie_device));
                    $("#cheng_jie_subbao").html(parseFormatNum(data.cheng_jie_subbao));

                    $("#cheng_fu_stuff").html(parseFormatNum(data.cheng_fu_stuff));
                    $("#cheng_fu_labour").html(parseFormatNum(data.cheng_fu_labour));
                    $("#cheng_fu_device").html(parseFormatNum(data.cheng_fu_device));
                    $("#cheng_fu_subbao").html(parseFormatNum(data.cheng_fu_subbao));
                    $("#cheng_fu_cuo").html(parseFormatNum(data.cheng_fu_cuo));
                    $("#cheng_fu_bao").html(parseFormatNum(data.cheng_fu_bao));


                    $("#xian_daofee").html(parseFormatNum(data.xian_daofee));
                    $("#xian_zhifee").html(parseFormatNum(data.xian_zhifee));
                    $("#xian_yufee").html(parseFormatNum(data.xian_yufee));


                    $("#piao_kai").html(parseFormatNum(data.piao_kai));
                    $("#piao_xiao").html(parseFormatNum(data.piao_xiao));
                    $("#piao_shou").html(parseFormatNum(data.piao_shou));
                    $("#piao_jin").html(parseFormatNum(data.piao_jin));
                    $("#piao_ying").html(parseFormatNum(data.piao_ying));


                    $("#jin_chanfee").html(parseFormatNum(data.jin_chanfee));
                    $("#jin_wanchan").html(parseFormatNum(data.jin_wanchan));
                    $("#jin_wanbi").html(parseFormatNum(data.jin_wanbi));
                    $("#jin_actualdt").html(data.jin_actualdt);
                    $("#jin_shiday").html(data.jin_shiday);


                    $("#xun_xunci").html(data.xun_xunci);
                    $("#xun_zhengci").html(data.xun_zhengci);
                    $("#xun_yizheng").html(data.xun_yizheng);
                    $("#xun_daizheng").html(data.xun_daizheng);
                    $("#xun_yuzheng").html(data.xun_yuzheng);


                    $("#nei_lian_unit").html(data.nei_lian_unit);
                    $("#nei_xiangshou").html(parseFormatNum(data.nei_xiangshou));
                    $("#nei_kou").html(parseFormatNum(data.nei_kou));
                    $("#nei_fu").html(parseFormatNum(data.nei_fu));
                    $("#nei_gongfu").html(parseFormatNum(data.nei_gongfu));
                    $("#nei_bao").html(parseFormatNum(data.nei_bao));
                    $("#nei_keyong").html(parseFormatNum(data.nei_keyong));


                    xmselect_dan('enginid', res.data.enginlist, res.data.is_enginid, function (res) {
                        get_engin_dan_home(res.change[0].id)
                    })

                    render_from();
                }
            });
        }

    });







</script>
</body>
</html>
